#ifndef SEARCHFIELD_H_
#define SEARCHFIELD_H_

#include <wx/wx.h>
#include "wx/listbox.h"
#include "../StdUserInterfaceModule/ImppPopupWindow.h"
#include "../../core/Buddy.h"
#include "BuddyList.h"

namespace Impp
{

class BuddyList;
class SearchResults;

class SearchField : public wxTextCtrl
{
private:
	BuddyList* list;
	SearchResults* results;

public:
	SearchField(BuddyList* list, wxWindow *parent, wxWindowID id);
	virtual ~SearchField();

	void trigger(const wxChar & c);
	void hideSearchField();

private:
	void onTextedChanged(wxCommandEvent & event);
	void onKillFocus(wxFocusEvent & event);
	void onKeyDown(wxKeyEvent & event);

	DECLARE_EVENT_TABLE()

};

class SearchResults : public ImppPopupWindow
{
private:
	SearchField* sf;
	wxListBox* list;
	std::vector<Buddy*> buddies;

public:
	bool hideSearchField;

public:
	SearchResults(SearchField *parent);
	~SearchResults();

	void setData(const std::vector<Buddy*> & buddies);
	void onItemActivated(wxCommandEvent & event);
	void onRightClicked(wxMouseEvent & event);

	void up();
	void down();
	void enter();


	DECLARE_EVENT_TABLE()
};

}

#endif /*SEARCHFIELD_H_*/
